export const state = () => ({
    fangwencishu: 0,
    commentindex: 0,
    keyid: 'c4341974cdcb4c61bd02aaac33e91b55',
    spot: '',
    spotid: '',
    result: [],
    comments: [],
    articleId: '',
    tuijian_spots: [],
    spot_list: [],
    isadmined: "",
    modify: {},
    test: "1"
})

export const mutations = {
    setCommentIndex(state, data) {
        state.commentindex = data
    },
    setSpot(state, data) {
        state.spot = data
            // state.spotid = state.spot.sid
    },
    setResult(state, data) {
        state.result = data
    },
    setComments(state, data) {
        state.comments = data
    },
    setTuijianSpots(state, data) {
        state.tuijian_spots = data
    },
    setArticleId(state, data) {
        state.articleId = data
    },
    setIsadmined(state, data) {
        state.isadmined = data
    },
    setSpotList(state, data) {
        state.spot_list = data
    },
    setModify(state, data) {
        state.modify = data
    },
    addFangwencishu(state) {
        state.fangwencishu++
    },
}

export const actions = {
    // const sid = state.spot.sid
    getComments({ commit }, data) {
        // setTimeout(1300)
        // console.log(state);
        return this.$axios.get('/api2/scenComment/list/' + data).then(res => {
            let data = res.data
            commit("setComments", data.list)
            Promise.resolve()
        })
    },
    getTuijianSpots({ commit }, data) {
        this.$axios.get('/api2/spot/tuijian/' + data).then(res => {
            let d = res.data
            commit("setTuijianSpots", d.list)
            this.$axios.get("/api2/article/spot_article?sid=" + data).then(res => {
                commit("setSpotList", res.data.list)
            })
        })
    }
}